#include "owncloudsetupwizard.h"
#include "accountmanager.h"
#include "guiutility.h"
+#include "capabilities.h"
#if defined(BUILD_UPDATER)
#include "updater/updater.h"
, _ui(new Ui::GeneralSettings)
{
_ui->setupUi(this);
-
- _ui->labelInterval->setText("seconds (if <a href=\"https://github.com/nextcloud/notify_push\">Client Push</a> is unavailable)");
- _ui->labelInterval->setTextFormat(Qt::RichText);
- _ui->labelInterval->setTextInteractionFlags(Qt::TextBrowserInteraction);
- _ui->labelInterval->setOpenExternalLinks(true);
+ updatePollIntervalVisibility();
+
connect(_ui->serverNotificationsCheckBox, &QAbstractButton::toggled,
this, &GeneralSettings::slotToggleOptionalServerNotifications);
_ui->serverNotificationsCheckBox->setToolTip(tr("Server notifications that require attention."));
_ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons());
const auto interval = cfgFile.remotePollInterval();
- _ui->remotePollIntervalSpinBox->setValue(static_cast<int>(interval.count() / 1000));
+ _ui->remotePollIntervalSpinBox->setValue(static_cast<int>(interval.count() / 1000));
+ updatePollIntervalVisibility();
}
#if defined(BUILD_UPDATER)
cfgFile.setRemotePollInterval(interval);
}
+void GeneralSettings::updatePollIntervalVisibility() {
+ const auto accounts = AccountManager::instance()->accounts();
+ const auto pushAvailable = std::any_of(accounts.cbegin(), accounts.cend(),
+ [](const AccountStatePtr &accountState) -> bool {
+ if (!accountState)
+ return false;
+ AccountPtr accountPtr = accountState->account();
+ if (!accountPtr)
+ return false;
+ return accountPtr->capabilities().availablePushNotifications().testFlag(PushNotificationType::Files);
+ });
+
+ _ui->horizontalLayoutWidget_remotePollInterval->setVisible(!pushAvailable);
+}
+
} // namespace OCC
</item>
</layout>
</item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout_remotePollInterval">
- <item>
- <widget class="QLabel" name="remotePollIntervalLabel">
- <property name="text">
- <string>Server poll interval</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QSpinBox" name="remotePollIntervalSpinBox">
- <property name="minimum">
- <number>30</number>
- </property>
- <property name="maximum">
- <number>999999</number>
- </property>
- <property name="singleStep">
- <number>1</number>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLabel" name="labelInterval">
- <property name="text">
- <string extracomment="Trailing part of "Server poll interval" ">seconds (if Client Push is unavailable)</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_remotePollInterval">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
- </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_10">
<item>
</item>
</layout>
</item>
+ <item>
+ <widget class="QWidget" name="horizontalLayoutWidget_remotePollInterval">
+ <layout class="QHBoxLayout" name="horizontalLayout_remotePollInterval">
+ <item>
+ <widget class="QLabel" name="remotePollIntervalLabel">
+ <property name="text">
+ <string>Server poll interval</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="remotePollIntervalSpinBox">
+ <property name="minimum">
+ <number>30</number>
+ </property>
+ <property name="maximum">
+ <number>999999</number>
+ </property>
+ <property name="singleStep">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="labelInterval">
+ <property name="text">
+ <string><html><head/><body><p>seconds (if <a href="https://github.com/nextcloud/notify_push"><span style=" text-decoration: underline; color:#2980b9;">Client Push</span></a> is unavailable)</p></body></html></string>
+ </property>
+ <property name="textFormat">
+ <enum>Qt::TextFormat::RichText</enum>
+ </property>
+ <property name="openExternalLinks">
+ <bool>true</bool>
+ </property>
+ <property name="textInteractionFlags">
+ <set>Qt::TextInteractionFlag::TextBrowserInteraction</set>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_remotePollInterval">
+ <property name="orientation">
+ <enum>Qt::Orientation::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>